<layout name="page" />
<block name="content">
	{:widget('page_header/simple',array('name'=>'发布任务'))}
	<div class="sub frame">
		<form method='post' id="form_data" name="form_data" enctype="multipart/form-data" >
			<input type="hidden" id="ajax" name="ajax" value="0">
			<input type="hidden" id="executor" name="executor" value="">
			<input type="hidden" id="opmode" name="opmode" value="add">
			<div class="box">
				<label class="input-label" for="name">标题：</label>
				<input class="input" type="text" id="name" name="name" value=""  check="required" info="请输入标题">
			</div>
			<div class="box">
				<label class="input-label" for="name">指派给：</label>
				<div id="executor_list" class="multi-select-box">
					<span class="data-list"></span>
					<input class="letter" type="text" >
					<label></label>
					<div class="search hidden">
						<ul></ul>
					</div>
				</div>
				<a class="add-on" onclick="select_executor();"><i class="fa fa-user"></i></a>
			</div>
			<div class="box">
				<label class="input-label" for="expected_time">期望完成时间：</label>
				<input class="input input-date-time w13" type="text" id="expected_time" name="expected_time" value="" readonly="readonly">
			</div>
			<div class="box">
				<label class="input-label" for="content">任务描述：</label>
				<textarea class="editor" id="content" name="content" style="width:100%;height:300px;" check="required" info="请输入内容"></textarea>
			</div>

			<div class="box">
				<label class="input-label" for="name">附件：</label>
				<div class="input-block">
					{:widget('file_upload/add')}
				</div>
			</div>
			<div class="box">
				<label class="input-label"></label>
				<a class="btn btn-normal" onclick="save();">保存</a>
				<a class="btn btn-return" onclick="go_return_url();">取消</a>
			</div>
		</form>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		layui.use(['global', 'editor'], function() {
			var fn = {
				save : function() {
					var executor = [];
					$("#executor_list span.data-list a").each(function() {
						$this = $(this);
						name = $this.text();
						data = $this.attr('data');
						executor.push({
							name : name,
							data : data
						});
					});

					$("#executor").val(JSON.stringify(executor));

					send_form('form_data', '{:url("save")}', '', function(ret) {
						if (ret.status == 1) {
							parent.layer.msg(ret.info);
							parent.layer.close(index);
							parent.location.reload(true);
						} else {
							parent.layer.msg(ret.info);
							return false;
						};
					});
				},
				select_executor : function() {
					winopen("{:url('select_executor')}", 560, 470);
				}
			};
			win_exp(fn);
		});
	</script>
</block>
